<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script>
    function $(id){
      return document.getElementById(id);
    }
    function submitForm(pn){
      $("pageNO").value = pn;
      $("f1").submit();
    }
  </script>
</head>
<body>
<div th:if="${session.loginUser == null}">
  请先<a href="/login.html">登陆</a>
</div>
<div th:if="${session.loginUser != null}"
     th:text="'欢迎光临'+${session.loginUser.userName}">
</div>

<div style="display: flex">
  <div style="width: 300px;height: 300px"
       th:each="p : ${pg.records}">
    <img th:src="'/imag/'+${p.imgPath}" width="200" height="200"><br>
    商品名：<span th:text="${p.name}"></span><br>
    单价：<span th:text="${p.price}"></span><br>
    <!--            评论数：<span-->
    <a th:href="@{/user/findById(id=${p.id})}">查看</a>
  </div>
</div>

<div>
  <a th:each="i : ${#numbers.sequence(1,pg.pages)}" th:text="${i}"
     style="margin-left: 10px" th:href="'javascript:submitForm('+${i}+')'"></a>
</div>
<form action="/user/findByItem" id="f1">
  <input type="hidden" id="pageNO" name="pageNO">
  商品名：<input  type="text" name="name" id="name">
  <input type="submit" value="提交">
</form>
</body>
</html>